package org.jeecg.modules.demo.jxcx.service.impl;

import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.demo.jxcx.Utils.R;
import org.jeecg.modules.demo.jxcx.mapper.JxcZfzdMapper;
import org.jeecg.modules.demo.jxcx.po.JxcZfzd;
import org.jeecg.modules.demo.jxcx.service.JxcZfzdService;
import org.springframework.stereotype.Service;

/**
* @author Administrator
* @description 针对表【jxc_zfzd】的数据库操作Service实现
* @createDate 2024-09-07 21:07:36
*/
@Service
public class JxcZfzdServiceImpl extends ServiceImpl<JxcZfzdMapper, JxcZfzd>
implements JxcZfzdService{


    @Override
    public JxcZfzd getByCompanyId(String companyId, String id) {
        return baseMapper.getByCompanyId(companyId, id);
    }

    @Override
    public R add(JxcZfzd jxcZfzd) {
        String tabledata = jxcZfzd.getTabledata();
        JSONArray jsonArray = JSONArray.parseArray(tabledata);
        String id = jsonArray.getJSONObject(0).getString("id");
        jxcZfzd.setId(id);
        return new R().ok(save(jxcZfzd));
    }
}
